/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb.supervisore;

import entity.Supervisore;
import facade.SupervisoreFacade;
import javax.ejb.EJB;
import javax.ejb.Stateful;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

/**
 *
 * @author Valerio
 */
@Stateful
public class SupervisoreEJB implements SupervisoreEJBLocal {
    @EJB
    private SupervisoreFacade supervisoreFacade;

    private Long idSupervisore;
    private String nome;
    
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public String getNome() {
        return nome;
    }

    @Override
    public void setNome(String nome) {
        this.nome=nome;
    }

    @Override
    public Long getIdSupervisore() {
        return idSupervisore;
    }

    @Override
    public void setIdSupervisore(Long id) {
        this.idSupervisore=id;
    }

    @Override
    public void setSupervisore(Supervisore supervisore) {
        this.idSupervisore=supervisore.getId();
        this.nome=supervisore.getNome();
    }

    @Override
    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    public Supervisore getSupervisore() {
        if(idSupervisore==null){
            return null;
        }
        return supervisoreFacade.find(this.idSupervisore);
    }
}
